<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>3264：Fib</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">Fib</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">Fib</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                Fib                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>在一个阴冷的夜晚，聪明的小Y回到了三国时代，这是他梦寐以求想要到达的时代。他来到了一个名曰三重镇的地方，在这个小镇的门口，他看见了首长。首长要求他给出进入小镇的通关密码。</div>
<div>通关密码由两部分组成，由于一些诡异的原因，它们的计算都依赖于一个函数F.</div>
<div><img width="631" height="135" alt="" src="../file/3264_0.jpg" /></div>
<div>通关密码的第一部分是一个函数G。</div>
<div>给定函数G(a,b,n,p)，定义如下：</div>
<div><img width="891" height="108" alt="" src="../file/3264_1.jpg" /></div>
<div>
<div>通关密码的第二部分是一个函数H.</div>
<div>给定函数H(n),定义如下：</div>
<div>H(1)=F(c^d)</div>
<div>H(n)=H(n-1)^f(c^d)</div>
<div>当你计算出了H和G后，通关密码也就浮出水面了。</div>
<div>最后的通关密码如下所示：</div>
<div>((H(m) mod q)*G(a,b,n,p))^2 mod M</div>
<div>现在，小Y向你求助。你的任务就是帮助他计算出这个通关密码，否则&hellip;&hellip;你将和小Y一起受到首长的审判。</div>
<div></div>
</div>
<p></p></p><hr/><h3>输入格式</h3><p><p style="margin: 0cm 0cm 0pt" class="MsoNormal"><span lang="ZH-HK" style="font-family: &quot;DejaVu Sans&quot;; mso-ascii-font-family: 'DejaVu Serif'; mso-hansi-font-family: 'DejaVu Serif'"><font size="3" face="宋体, MS Song">每个测试点有若干组数据。</font></span></p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal"><font size="3"><font face="宋体, MS Song"><span lang="ZH-HK" style="font-family: &quot;DejaVu Sans&quot;; mso-ascii-font-family: 'DejaVu Serif'; mso-hansi-font-family: 'DejaVu Serif'">每组数据一行，一行依次为九个整数</span><span lang="EN-US">a,b,n,p,c,d,m,q,M</span></font></font></p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal"><span lang="EN-US"><o:p><font size="3" face="宋体, MS Song">&nbsp;</font></o:p></span></p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal"><span lang="EN-US"><o:p><font size="3" face="宋体, MS Song">&nbsp;</font></o:p></span></p>
<p></p></p><hr/><h3>输出格式</h3><p><p style="margin: 0cm 0cm 0pt" class="MsoNormal"><span lang="ZH-HK" style="font-family: 'DejaVu Sans'; mso-ascii-font-family: 'DejaVu Serif'; mso-hansi-font-family: 'DejaVu Serif'"><font size="3" face="宋体, MS Song">每组数据输出一行，每行输出整数，为最后答案。</font></span></p></p><hr/><h3>样例输入</h3><pre>45060610 18752779 3 84732859 3 3 681333 129 632645608
11471798 17317802 8 44535607 7 3 847749 277 540541577
1875470 284505 9 2381651 7 5 890291 200 413141273
40160162 2604524 10 82886393 1 5 294503 255 695547562
56660246 59682524 10 59978983 5 3 411521 68 858119089
33788108 43618184 9 75780907 5 3 718429 76 412293725
12907969 16598067 6 19930843 7 1 979008 209 417203329
42974584 54976899 3 67136551 4 6 104941 42 845364347
4335596 1710083 5 6810263 7 3 929019 290 26807149
3354401 6896271 5 31175233 1 4 197763 197 824125328
5083697 9311265 1 86249521 5 3 416564 132 448188429
5163372 1927245 1 9923747 2 2 882917 201 82288053
24279309 29928975 9 35206547 5 5 13213 181 590631537
3985641 1437240 3 33697243 6 5 690823 157 191065249
10152964 8899799 8 27589229 3 3 931641 213 82068220
40982887 33478308 1 54279377 7 6 703865 94 639444379
24171099 21577049 1 35974987 10 3 994569 295 552456417
28712393 31802540 5 35459717 5 5 170689 168 534370369
1883952 2617730 3 4360171 1 3 308955 89 110855997
63733 331779 1 1401977 9 5 719201 198 432340401
36777506 57226864 10 59677903 3 4 566603 151 558644334
69808604 4279044 5 96645881 1 5 700993 193 946861303
47419399 21519505 9 60152441 7 3 679989 73 421363297
10886509 30699814 1 40071061 6 4 347529 214 566205591
15125363 46605946 5 51085891 3 2 97654 274 923809477
49769245 3379031 3 92060959 6 6 221243 67 687710785
6372713 1542613 10 22462051 5 5 865249 125 316014163
21613597 6533757 1 29453063 6 1 423623 250 150093121
21559540 43037178 5 53950703 4 5 519209 269 852743752
24468568 37135633 5 49658711 7 1 462015 133 959869912
45933297 35218178 3 85643387 4 6 741541 49 531671271
20910501 22743181 5 52854719 6 1 32145 144 308001
843719 854106 1 2739733 6 3 883985 219 678242157
55237955 51984542 5 95099929 1 1 877025 208 806864847
30663096 22690033 3 55149767 10 3 179113 181 992417646
21851576 36286348 10 39651641 1 1 655963 283 49585921
80945322 51658726 9 91886843 8 6 648570 2 774853178
42714047 44626502 6 63280031 9 6 479175 105 816604617
48249182 60920321 8 64350233 1 5 101062 263 397316619
4565141 12919795 1 14032787 5 3 982647 97 307574260
3016917 21219426 3 80791687 3 4 464749 193 778962812
66165874 69099737 6 76538359 9 1 975041 239 586699857
4450626 13939371 9 22489937 9 1 905725 28 290184533
5851519 34693563 6 83026921 3 3 383529 65 894683051
279616 760249 4 1088987 8 3 741871 293 145043305
15129679 31339920 1 58198069 9 4 856373 245 498830521
20393706 4487958 1 26310187 7 6 560161 198 33166361
7558489 23477403 1 33274727 3 2 901537 93 188526258
78844260 69521307 5 98827529 7 1 803619 225 448012527
25162995 31824613 9 45046051 3 5 223709 154 400366641
</pre><hr/><h3>样例输出</h3><pre>0
0
0
0
0
0
0
718779931
14892616
206243444
373973076
0
484156581
55198689
0
0
0
0
28289038
0
0
0
0
0
850697223
624621310
0
0
0
266521000
0
0
0
178171831
0
0
0
609693982
81465832
0
0
0
0
0
0
285177193
0
2692584
0
257250673
</pre><hr/><h3>提示</h3><p><p>p是奇质数，a,b &lt;= 10^9,q &lt;= 300，N&lt;=2*10^9,M&lt;=10^9,c^d&lt;=10^18,M&lt;=10^18</p>
<p>题 解http://pan.baidu.com/s/1o7scREE</p>
<p></p></p><hr/><h3>题目来源</h3><p>没有写明来源</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=3264" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=3264" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>